package com.zlgs.cqyf.vote;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * 	Description: 
 *	author:xurui 
 *	ProjectName: yf-vote
 *	PackageName: com.yf.connect
 *	ClassName  : ConnectionUtil
 *	Date:  2020年11月21日
 **/
public class ConnectionUtil {

	public static boolean is_local = false;
	private static Connection conn = null;
	private static String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";//SQL数据库引擎
	private static String local_url="jdbc:sqlserver://47.110.88.212:1433;DatabaseName=test111";//数据源  ！！！注意若出现加载或者连接数据库失败一般是这里出现问题
	private static String local_name="sa";
	private static String local_pwd="Pass@Word1";
	private static String url="jdbc:sqlserver://10.125.138.83:1433;DatabaseName=ECOLOGY";//数据源  ！！！注意若出现加载或者连接数据库失败一般是这里出现问题
	private static String name="jcimes";
	private static String pwd="Move4faster";
	
	public static Connection getConnection() {
		try {
	            synchronized(ConnectionUtil.class){
	            	Class.forName(driverName);
	    			//建立连接
	    			if (is_local){
	    				conn =  DriverManager.getConnection(local_url,local_name,local_pwd);
	    			}else {
	    				conn =  DriverManager.getConnection(url,name,pwd);
	    			}       
	            }        
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			return conn;
		}
		
		
	}
	
}
